import Vue from 'vue'
import Vuex from 'vuex'
import notification from './modules/notification'
import user from './modules/user'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    count: 1,
    users: [
      {name: 'tbf', 'age': 27},
      {name: 'tea', 'age': 20},
      {name: 'tang', 'age': 2}
    ]
  },
  getters: {
    youthUsers: state => state.users.filter(user => user.age < 21)
  },
  mutations: {
    increment: state => {
      // 变更状态
      state.count++
    }
  },
  actions: {
    increment: context => {
      context.commit('increment')
    }
  },
  modules: {
    user: user,
    notification: notification
  }
})
